package sk.avicularia.core.data;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import sk.avicularia.core.dao.AccessDAO;
import sk.avicularia.core.dao.DocumentAccessDAO;
import sk.avicularia.core.dao.DocumentDAO;

/**
* Entita mapujuca strukturu pravo dokumentu
* 
* @author leaflock
* @since  0.1
*/
@Entity
@Table(name = DocumentAccessDAO.TABLE_NAME)
public class DocumentAccess implements Serializable
{

	/**
	 * @see Serializable
	 */
	private static final long	serialVersionUID	= -8381278797526030889L;

	/**
	 * Id zaznamu
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID", nullable = false)
	private Long id;
	
	/**
	 * Dokument na ktore sa vztahuje dane pravo
	 */
	@ManyToOne(fetch = FetchType.LAZY)	
	@JoinColumn(name = DocumentAccessDAO.COLUMN_ID_DOCUMENT, referencedColumnName = "ID", table = DocumentDAO.TABLE_NAME)
	private Document document;
	
	/**
	 * Pravo pre dany zaznam
	 */
	@ManyToOne(fetch = FetchType.LAZY)	
	@JoinColumn(name = DocumentAccessDAO.COLUMN_ID_ACCESS, referencedColumnName = "ID", table = AccessDAO.TABLE_NAME)
	private Access access;

	public Long getId()
	{
		return id;
	}

	public void setId(Long id)
	{
		this.id = id;
	}

	public Document getDocument()
	{
		return document;
	}

	public void setDocument(Document document)
	{
		this.document = document;
	}

	public Access getAccess()
	{
		return access;
	}

	public void setAccess(Access access)
	{
		this.access = access;
	}
}
